package com.itlaoqi.thread;

import java.util.Random;

public class Match2 {
    public static void main(String[] args) {
        Runner2 liuxiang = new Runner2();
        Thread thread1 = new Thread(liuxiang);
        thread1.setName("刘翔");
        thread1.start();

        Thread laoqi = new Thread(new Runner2());
        laoqi.setName("老齐");
        laoqi.start();

        Thread lufei = new Thread(new Runner2());
        lufei.setName("路飞");
        lufei.start();
    }
}
class Runner2 implements Runnable{
    @Override
    public void run() {
        Integer speed = new Random().nextInt(100);
        for (int i = 0;i<100;i++){
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            //this.getName()打印当前线程的名字
            System.out.println(Thread.currentThread().getName() + "以前进" + (i * speed) + "米（" + speed + "米/秒）");
        }
    }
}
